#ifndef AT_NETWORK_MQTT_CLIENT_EC800_h
#define AT_NETWORK_MQTT_CLIENT_EC800_h

#include "./AtNetworkMqttRouteEC800.h"
#include "./AtNetworkMqttStateEC800.h"

#include "extend/mqtt/AtNetworkMqttClient.h"

class AtNetworkMqttClientEC800 : public AtNetworkMqttClient {
  protected:
    AtNetworkMqttRouteEC800 *route;
    AtNetworkMqttStateEC800 *state;

  public:
    // +QMTRECV: <client_idx>,<msgid>,<topic>[,<payload_len>],<payload>
    // +QMTSTAT: <client_idx>,<err_code>
    AtNetworkMqttClientEC800(AtNetworkDevice *device, uint16_t cid = 0);

    ~AtNetworkMqttClientEC800();

    /**
     * 发布数据
     */
    virtual bool publish(const char *topic, char *body, size_t length);

    /**
     * 订阅主题
     */
    virtual bool subscribe(AtNetworkMqttTopic *topic, uint8_t qos);

    /**
     * 取消订阅主题
     */
    virtual bool unsubscribe(AtNetworkMqttTopic *topic);

    /**
     * 判定当前MQTT服务是否连接成功
     */
    virtual bool isConnected(uint32_t timeout = 1000);

    /**
     * 断开连接
     * @param timeout 超时时长
     */
    virtual bool diconnect(uint32_t timeout = 10000);

    /**
     * 初始化MQTT服务
     * @param timeout 超时时长
     */
    virtual bool connect(uint32_t timeout = 10000);
};

#endif